<? include("admin/function.php"); ?>
<?
$chk = Q1("select cr_id from cart WHERE pd_id  = '".$pd_id."' and cr_ip = '".session_id()."' and cr_date = '".date("Y-m-d")."' and cr_img='$img_id'  LIMIT 1");  
		if($chk[0] >= 1) { echo "x**รายการสินค้านี้มีใน cart แล้ว "; exit;} // hide add
		else {   // show add
	
?>
<?
$valuearray['pd_id'] = $_REQUEST['pd_id'];
$valuearray['cr_size'] = $_REQUEST['pdsize'];
$valuearray['cr_color'] = $_REQUEST['pdcolor'];
$valuearray['cr_ea'] = $_REQUEST['pdea'];
$valuearray['cr_ip'] = session_id();
$valuearray['cr_date'] = date("Y-m-d");
$maxorder = Q1("select MAX(cr_order) from cart  ");
$valuearray['cr_order'] = $maxorder[0]+1;
$valuearray['cr_staus'] = 0;
$valuearray['cr_img'] = $img_id;
Qinsert("cart","",$valuearray);
?>


    	<a href="#" onclick="showdiv('addcart','ajax_addtocart.php?pd_id=<?=$_GET['pd_id']?>&img_id='+img_id);return false;"><img src="images/addtobagx.gif" alt="Add to cart" title="Add to cart" height="40" /></a>

	<?}?>